package com.study.edoc.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.ResourceUtils;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.File;

@Configuration
public class WebAppConfig implements WebMvcConfigurer {


    @Value("${web.upload-path}")
    private String filesPath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //<mvc:resource mapping="/statics/**" location="file:E:\\upload\\files\\"/>
        registry.addResourceHandler("/statics/**").addResourceLocations(ResourceUtils.FILE_URL_PREFIX+ filesPath+ File.separator);
    }
}
